Skip to content

[codex] Fix preview automation edge cases#3561

Merged
juliusmarminge merged 1 commit into
mainfrom
codex/preview-automation-polish
Jun 26, 2026
Merged

[codex] Fix preview automation edge cases#3561
juliusmarminge merged 1 commit into
mainfrom
codex/preview-automation-polish

Conversation

@juliusmarminge

@juliusmarminge juliusmarminge commented Jun 26, 2026

Copy link
Copy Markdown
Member

Why

This is a focused follow-up to #3548 based on the final installed-build smoke test.

Two small automation edge cases remained:

  • On macOS, preview_press delivered trusted Meta+A keyboard events, but Chromium did not perform the native Select All editing action. Agents could emit the chord while the focused field remained unchanged.
  • Opening a preview without an initial URL created the intended idle tab, but the request still waited for a desktop webview readiness condition. Because an empty tab has no navigation to become ready, preview_open could time out even though the tab had been created successfully.

Root cause

Chromium's debugger input API does not infer macOS editing commands from synthetic Meta chords. Those commands must be attached explicitly to the key-down packet.

The preview automation host also treated every open operation as if it needed navigated guest content. URL-less idle sessions only need the tab and panel state; requiring the rendered overlay made their completion depend on unrelated webview initialization.

How

  • Add the common macOS editing and navigation command mappings to preview keyboard packets, gated by the injected host platform. This covers Select All, copy/cut/paste, undo/redo, document and line navigation, selection variants, and delete-to-line-start.
  • Keep non-macOS key packets unchanged.
  • Skip the desktop-overlay wait only when preview_open is opening or reusing an idle tab without a URL. Opens with a URL and tabs with existing content retain the existing readiness wait.
  • Add focused packet, manager-layer, and open-readiness regression coverage.

Validation

  • vp test apps/desktop/src/preview/PreviewKeyboard.test.ts apps/desktop/src/preview/Manager.test.ts apps/web/src/components/preview/previewAutomationOpenReadiness.test.ts — 27 tests passed
  • vp check — passed
  • vp run typecheck — all 15 packages passed

Note

Fix preview automation edge cases for macOS key events and overlay wait conditions

  • Adds a commands field to PreviewAutomationKeyEvent and populates it with Chromium editing commands when running on macOS hosts, so Meta-chord shortcuts (e.g. Cmd+C) are handled correctly in the preview.
  • Reads the host OS platform from Effect context in Manager.ts and passes isMac to makePreviewAutomationKeySequence so platform-specific key sequences are generated correctly.
  • Introduces previewAutomationOpenNeedsOverlay in previewAutomationOpenReadiness.ts to conditionally skip waiting for the desktop overlay when opening a preview into an empty tab with no URL.
  • Behavioral Change: automation open no longer unconditionally waits for the desktop overlay; it waits only when a URL is provided or the tab already has rendered content.

Macroscope summarized 4ba8c96.


Note

Low Risk
Targeted preview automation behavior with regression tests; no auth, data, or broad API surface changes.

Overview
Fixes two preview automation edge cases: macOS Meta shortcuts not performing native editing actions, and preview_open timing out on URL-less idle tabs.

On darwin, makePreviewAutomationKeySequence now attaches Chromium CDP commands (select all, copy/cut/paste, undo/redo, line/document navigation, etc.) to synthetic Meta chords; PreviewManager reads HostProcessPlatform and passes isMac into key dispatch. Non-macOS packets are unchanged.

For open, the web automation host only waits for the desktop webview overlay when previewAutomationOpenNeedsOverlay says so—i.e. when a URL is provided or the session is not idle. Reusing or creating an empty idle tab no longer blocks on overlay readiness.

Reviewed by Cursor Bugbot for commit 4ba8c96. Bugbot is set up for automated code reviews on this repo. Configure here.

Co-authored-by: codex <codex@users.noreply.github.com>
@coderabbitai

coderabbitai Bot commented Jun 26, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: ca05edc0-8775-4578-a2ee-46da39c72009

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/preview-automation-polish

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added size:M 30-99 changed lines (additions + deletions). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. labels Jun 26, 2026
@juliusmarminge
juliusmarminge marked this pull request as ready for review June 26, 2026 02:29
@macroscopeapp

macroscopeapp Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved

Straightforward bug fixes for preview automation edge cases: adds macOS editing command support for Chromium synthetic key events and optimizes overlay waiting logic for empty tabs. Changes are well-tested and self-contained.

You can customize Macroscope's approvability policy. Learn more.

@juliusmarminge
juliusmarminge merged commit e9ed70c into main Jun 26, 2026
21 checks passed
@juliusmarminge
juliusmarminge deleted the codex/preview-automation-polish branch June 26, 2026 03:08
aaditagrawal pushed a commit to aaditagrawal/t3code that referenced this pull request Jun 26, 2026
Co-authored-by: codex <codex@users.noreply.github.com>
aaditagrawal added a commit to aaditagrawal/t3code that referenced this pull request Jun 26, 2026
<!--
⚠️ READ BEFORE OPENING ⚠️

We are not actively accepting contributions right now.

You can still open a PR, but please do so knowing there is a high chance
we may close it without merging it, or never review it.

- Small, focused PRs are strongly preferred. Bug fixes are most likely to be merged.
- New features will most likely just annoy us.
- 1,000+ line PRs with a bunch of new features will probably get you banned from the repo.
-->

## What Changed

<!-- Describe the change clearly and keep scope tight. -->

## Why

<!-- Explain the problem being solved and why this approach is the right one. -->

## UI Changes

<!-- If this PR changes UI, include clear before/after screenshots.
     If the change involves motion or interaction, include a short video.
     Delete this section if not applicable. -->

## Checklist

- [ ] This PR is small and focused
- [ ] I explained what changed and why
- [ ] I included before/after screenshots for any UI changes
- [ ] I included a video for animation/interaction changes
chanyeinthaw pushed a commit to sats-lab/pulse that referenced this pull request Jun 28, 2026
Co-authored-by: codex <codex@users.noreply.github.com>
simonbetton pushed a commit to simonbetton/reviewer that referenced this pull request Jun 29, 2026
Co-authored-by: codex <codex@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M 30-99 changed lines (additions + deletions). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant